<?php
/**
 * 文章SERVICE
 *
 * User: kaikaic
 * Date: 2018/4/12
 * Time: 17:52
 */

namespace app\exam\service;

use service\BasicService;
use think\Db;

class ArticleService extends BasicService {

    public function init() {
        $this->dataTable = ['Articles'];
    }

    /**
     * 推荐|取消
     * @param $id
     * @param bool $flag
     * @return bool
     */
    public function recommend($id, $flag=true) {
        $val = ($flag == true) ? 1 : 0;
        return false !== Db::name($this->dataTable[0])->where('id', $id)->update(['recommend'=>$val]);
    }
}
